/**
  @(#)$Id: AL_NewTypesDefine.h 69 2013-10-08 03:03:33Z xiaoting $
  @brief    	New Type Define

  @author		$Author: xiaoting $
  @date			$Date: 2013-10-08 11:03:33 +0800 (周二, 08 十月 2013) $
  @version		$Revision: 69 $
  @url			$URL: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_StandardLib/groupinc/AL_NewTypesDefine.h $
  @header		$Header: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_StandardLib/groupinc/AL_NewTypesDefine.h 69 2013-10-08 03:03:33Z xiaoting $
 */
#ifndef CXX_AL_NEWTYPESDEFINE_H
#define CXX_AL_NEWTYPESDEFINE_H

/*=============================================================================*/
/*Base Type (LINUX / WINDOWS)                                                  */
#if defined(_LINUX) || defined(_FOR_ANDROID_) || defined(_FOR_IPHONE_)
	/*=============================================================================*/
	/*include of Linux                                                             */
	#include <string.h>
	#include <stdio.h>
	#include <stdlib.h>
	#include <stdint.h>
	#include <ctype.h>
	#include <wchar.h>
	#include <errno.h>
	#include <unistd.h>

	/*=============================================================================*/
	/*redefinition of Linux                                                        */
	typedef signed char BOOL;
	typedef void *HANDLE;
	typedef int	HWND;
	typedef unsigned char BYTE;
	typedef int	INT;
	typedef short SHORT;
	typedef unsigned int UINT;
	typedef unsigned short UINT16;
	typedef unsigned short USHORT, WORD;
	typedef unsigned long ULONG, DWORD, *PDWORD;
	typedef long LONG;
	typedef int64_t INT64,__int64;
	typedef int64_t LONGLONG;
	typedef uint64_t ULONGLONG;
	typedef float		FLOAT;
	//typedef double      DOUBLE;

	typedef void *PVOID;
	typedef void *LPVOID;
	typedef const void *LPCVOID;
	typedef BYTE *PBYTE;
	typedef INT *PINT;

	typedef unsigned char UCHAR;
	typedef char CHAR, *PCHAR, *LPSTR, *PSTR;
	typedef const CHAR	*LPCSTR;
	typedef wchar_t WCHAR;
	typedef WCHAR *LPCWSTR, *PCWSTR;

	#if defined(UNICODE) || defined(_UNICODE)
	typedef wchar_t TCHAR, *PTCHAR;
	typedef const WCHAR *PCTSTR, *LPCTSTR;
	typedef WCHAR *LPTSTR;
	#define __TEXT(quote) L##qutoe
	#else //UNICODE || _UNICODE
	typedef CHAR TCHAR, *PTCHAR;
	typedef const CHAR  *PCTSTR, *LPCTSTR;
	typedef CHAR  *LPTSTR;
	#define __TEXT(quote) quote
	#endif //UNICODE || _UNICODE

	#define TEXT(quote) __TEXT(quote)
	#define _T(x)	TEXT(x)

	#define MAXLONG 0x7fffffffL
	#define MAXWORD 0xffff

	#ifndef MAX_PATH
	#   define MAX_PATH 260
	#   define _MAX_PATH MAX_PATH
	#endif

	#if defined(UNICODE) || defined(_UNICODE)
	#   define _tcschr wcschr
	#   define _tcslen wcslen
	#   define _tcscpy wcscpy
	#   define _tcsncpy wcsncpy
	#   define _tcschr wcschr
	#   define _tcsrchr wcsrchr
	#   define _tcscmp wcscmp
	#   define _tcsncmp wcsncmp
	#   define _stprintf swprintf
	#   define _sntprintf swprintf
	#   define _vsntprintf vswprintf
	#   define lstrcmp wcscmp
	#   define lstrcmpi wcscmp
	#   define lstrcpy wcscpy
	#   define _wcsupr wcsupr
	#   define _wcslwr wcslwr
	#   define _wcsicmp wcscasecmp
	#   define _wcsnicmp wcsncasecmp
	#else //UNICODE || _UNICODE
	#   define _tscchr strchr
	#   define _tcslen strlen
	#   define _tcscpy strcpy
	#   define _tcsncpy strncpy
	#   define _tcschr strchr
	#   define _tcsrchr strrchr
	#   define _tcscmp strcmp
	#   define _tcsncmp strncmp
	#   define _stprintf sprintf
	#   define _snprintf snprintf
	#   define _sntprintf snprintf
	#   define _vsntprintf vsnprintf
	#   define lstrcmp strcmp
	#   define lstrcmpi strcmp
	#   define lstrcpy strcpy
	#   define _strupr strupr
	#   define _strlwr strlwr
	#   define _stricmp strcasecmp
	#   define _strnicmp strncasecmp
	#endif //UNICODE || _UNICODE
	#define _vsnprintf vsnprintf
	#define _vsnwprintf vswprintf

	#ifndef CONST
	#   define CONST const
	#endif

	#ifndef VOID
	#   define VOID void
	#endif

	#ifndef FALSE
	#   define FALSE 0
	#endif

	#ifndef TRUE
	#   define TRUE 1
	#endif
#else		// _LINUX
	#include <wtypes.h>
#endif

/*=============================================================================*/
/*redefine for NewTypeDefine.h                                                 */

/*=============================================================================*/
/*redefine for NChar.h                                                         */
#ifdef NSTRING_UNICODE

typedef WCHAR NCHAR;
#define NTEXT(C) L##C
#define NCHARstrcat		wcscat
#define NCHARstrchr		wcschr
#define NCHARstrcmp		wcscmp
#define NCHARstrcpy		wcscpy
#define NCHARstrcspn	wcscspn
#define NCHARstrlen		wcslen
#define NCHARstrncat	wcsncat
#define NCHARstrncmp	wcsncmp
#define NCHARstrncpy	wcsncpy
#define NCHARstrpbrk	wcspbrk
#define NCHARstrrchr	wcsrchr
#define NCHARstrspn		wcsspn
#define NCHARstrstr		wcsstr
#define NCHARstrtok		wcstok
#define NCHARisalnum	iswalnum
#define NCHARisalpha	iswalpha
#define NCHARiscntrl	iswcntrl
#define NCHARisdigit	iswdigit
#define NCHARisgraph	iswgraph
#define NCHARislower	iswlower
#define NCHARisprint	iswprint
#define NCHARispunct	iswpunct
#define NCHARisspace	iswspace
#define NCHARisupper	iswupper
#define NCHARisxdigit	iswxdigit
#define NCHARtolower	towlower
#define NCHARtoupper	towupper
#define NCHARsprintf	swprintf
#define NCHARatoi		_wtoi
#define NCHARatol		_wtol
#define NCHARstrtod		wcstod
#define NCHARstrtol		wcstol
#define NCHARstrtoul	wcstoul
#define NCHARstrlwr		_wcslwr
#define NCHARstrupr		_wcsupr
#define NCHARstricmp	_wcsicmp
#define NCHARstrnicmp	_wcsnicmp

#define NCHARvsnprintf		_vsnwprintf

//file
#define NCHARfstream	std::wfstream
#define NCHARifstream	std::wifstream
#define NCHARfostream	std::wofstream


#else //NSTRING_UNICODE

typedef char NCHAR;
#define NTEXT(C) C
#define NCHARstrcat		strcat
#define NCHARstrchr		strchr
#define NCHARstrcmp		strcmp
#define NCHARstrcpy		strcpy
#define NCHARstrcspn	strcspn
#define NCHARstrlen		strlen
#define NCHARstrncat	strncat
#define NCHARstrncmp	strncmp
#define NCHARstrncpy	strncpy
#define NCHARstrpbrk	strpbrk
#define NCHARstrrchr	strrchr
#define NCHARstrspn		strspn
#define NCHARstrstr		strstr
#define NCHARstrtok		strtok

#define NCHARisalnum	isalnum
#define NCHARisalpha	isalpha
#define NCHARiscntrl	iscntrl
#define NCHARisdigit	isdigit
#define NCHARisgraph	isgraph
#define NCHARislower	islower
#define NCHARisprint	isprint
#define NCHARispunct	ispunct
#define NCHARisspace	isspace
#define NCHARisupper	isupper
#define NCHARisxdigit	isxdigit
#define NCHARtolower	tolower
#define NCHARtoupper	toupper

#define NCHARsprintf	sprintf
#define NCHARatoi		atoi
#define NCHARatol		atol
#define NCHARstrtod		strtod
#define NCHARstrtol		strtol
#define NCHARstrtoul	strtoul

#define NCHARstrlwr		_strlwr
#define NCHARstrupr		_strupr

///Perform a lowercase comparison of strings.
#define NCHARstricmp	_stricmp
///Compare characters of two strings without regard to case.
#define NCHARstrnicmp	_strnicmp

#define NCHARvsnprintf	_vsnprintf

//file
#define NCHARfstream	std::fstream
#define NCHARifstream	std::ifstream
#define NCHARfostream	std::ofstream

#endif //UNICODE || _UNICODE

/*=============================================================================*/
/*Custom macros														           */
#if defined(_LINUX) || defined(_FOR_ANDROID_) || defined(_FOR_IPHONE_)
#define _LINUX_AL_
#else	// LINUX) || defined(_FOR_ANDROID_) || defined(_FOR_IPHONE_
#define _WINDOWS_AL_
#endif	// WINDOWS

/*=============================================================================*/
/*redefine for others                                                          */
#ifndef MAX
#   define MAX(a,b)	(((a)>(b))?(a):(b))
#endif

#ifndef MIN
#   define MIN(a,b)	(((a)<(b))?(a):(b))
#endif

#if defined(_WIN32) || defined(_WIN32_WCE)
typedef WCHAR UCHAR16;
#else
typedef UINT16 UCHAR16;
#endif

//other base class
#ifndef CXX_AL_STRING_H
#include "AL_String.h"
#endif

#endif // CXX_AL_NEWTYPESDEFINE_H
/* EOF */

